﻿using VisualPureBasicIDE.CoreGUI.Extensibility;

namespace VisualPureBasicIDE.CoreGUI.OptionPanels
{
    public partial class Environment_PluginsPanel : OptionsPanel
    {
        public Environment_PluginsPanel()
        {
            InitializeComponent();

            DisplayPluginsInfo();
        }

        private void DisplayPluginsInfo()
        {
            foreach (var plugin in PluginManager.Plugins)
            {
                var actions = string.Empty;

                for (var i = 0; i < plugin.MenuItem.DropDownItems.Count; i++)
                {
                    if (i == plugin.MenuItem.DropDownItems.Count - 1)
                        actions += plugin.MenuItem.DropDownItems[i].Text;
                    else
                        actions += plugin.MenuItem.DropDownItems[i].Text + "; ";
                }

                var item = listViewPlugins.Items.Add(plugin.Name);
                item.SubItems.AddRange(new[] { "N/A", plugin.Description, actions });
            }
        }
    }
}